<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>03</title>
    <script>
      // 两个页面都设置
      //   document.domain = "www.baidu.com";
      function ajax(url) {
        return new Promise(function (resolve, reject) {
          var xhr = new XMLHttpRequest();
          xhr.open("GET", url);
          xhr.responseType = "json";
          xhr.onload = function () {
            if (this.status === 200) {
              resolve(this.response);
            } else {
              reject(new Error(this.statusText));
            }
          };
          xhr.send();
        });
      }

      ajax("D:/__easyProjects__/VScode/Web/Async/user.json").then(
        function (res) {
          console.log(res);
        },
        function (err) {
          console.log(err);
        }
      );
    </script>
  </head>
  <body>
    <h1>03-main</h1>
  </body>
</html>
